using System;
using System.Windows.Forms;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.CompositeUI.EventBroker;

namespace DeblectorAddIn.WorkItems
{
    [SmartPart]
    public partial class ShellOutput : UserControl
    {
        public ShellOutput()
        {
            InitializeComponent();
        }
        
        public RichTextBox Box
        {
            get
            {
                return richTextBox1;
            }
        }
        [EventPublication("event://executecommand",PublicationScope.WorkItem)]
        public event EventHandler<CommandEventArgs> ExecuteCommand;
        private void textCommand_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                if (null != ExecuteCommand)
                {
                    ExecuteCommand(this, new CommandEventArgs(textCommand.Text));
                    textCommand.Clear();
                    textCommand.Focus();
                }
            }
        }
    }
    public class CommandEventArgs : EventArgs
    {
        public CommandEventArgs(string cmd)
        {
            _cmd = cmd;
        }
        private string _cmd;

        public string Command
        {
            get { return _cmd; }
            
        }
	
    }
}
